package com.start;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.embedded.ConfigurableEmbeddedServletContainer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerCustomizer;
import org.springframework.boot.context.embedded.EmbeddedServletContainerFactory;
import org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.cloud.client.circuitbreaker.EnableCircuitBreaker;
import org.springframework.cloud.netflix.zuul.EnableZuulProxy;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import com.diandian.common.Constant;
import com.diandian.common.ErrorFilter;
import com.diandian.ddop.DdOpFilter;
import com.diandian.mobile.MobileFilter;
import com.diandian.ms.MobileServerFilter;
import com.diandian.util.EmailSender;

@SpringBootApplication
@EnableZuulProxy
@EnableConfigurationProperties({EmailSender.class,Constant.class})
//@EnableCircuitBreaker
@EnableAutoConfiguration
public class ZuulApplication /* implements EmbeddedServletContainerCustomizer*/{

	public static void main(String[] args) {
		SpringApplication.run(ZuulApplication.class, args);
	}


	@Bean
	public EmbeddedServletContainerFactory servletContainer() {
		TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory();
	    return factory;

	}
	
	
//	/**
//	 * 实现特定化端口号
//	 * extends EmbeddedServletContainerCustomizer
//	 */
//	public void customize(ConfigurableEmbeddedServletContainer configurableEmbeddedServletContainer) {  
//		
//        configurableEmbeddedServletContainer.setPort(8888);  
//    } 
	
	
	
	@Bean
	public DdOpFilter opFilter() {
		return new DdOpFilter();
	}
	
	@Bean
	public MobileFilter mobileFilter() {
		return new MobileFilter();
	}
	
	@Bean
	public MobileServerFilter mobileServerFilter() {
		return new MobileServerFilter();
	}
	
	@Bean
	public ErrorFilter errorFilter() {
		return new ErrorFilter();
	}
	
}